package commands;



import nanoxml.XMLElement;
import utils.ITransmittable;

/**
 * This command represent the reply from the DB containing 
 * a client's statistics.
 */
public class CommandStatistics implements ITransmittable {
    
    private final static String ATTR_USER_NAME = "Username";
    private final static String ATTR_WINS_NUM = "WinsNum";
    private final static String ATTR_LOSE_NUM = "LoseNum";
    
    private String username = null;
    private String winNum = null;
    private String loseNum = null;
     
    public CommandStatistics (String username,String winNum, String loseNum) {
    	this.username = username;
    	this.winNum = winNum;
    	this.loseNum = loseNum;
    }
    
    public CommandStatistics (XMLElement command) {
		this.username = (String) command.getAttribute(ATTR_USER_NAME);	
		this.winNum = (String) command.getAttribute(ATTR_WINS_NUM);
		this.loseNum = (String) command.getAttribute(ATTR_LOSE_NUM);
	}
   	
    @Override
	public XMLElement toXML () {
		XMLElement element = new XMLElement();
		element.setName(Commands.STATISTICS);
		element.setAttribute(ATTR_USER_NAME, username);
		element.setAttribute(ATTR_WINS_NUM, winNum);
		element.setAttribute(ATTR_LOSE_NUM, loseNum);

		return element;
	}

    public String getUserName() {
        return username;
    }
    
    public String getWinNum() {
        return winNum;
    }
    
    public String getLoseNum() {
        return loseNum;
    }
    
	public void setWins(String WinsNum) {
		this.winNum = WinsNum;
	}
	 
	public void setLose(String LoseNum) {
		this.loseNum = LoseNum;
	}	
    
}
